home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Resources / Online / Term / Extras / Source / gtlayout-source.lha / LTP_HandleHistory.c < prev    next >
C/C++ Source or Header  |  1996-08-22  |  2KB  |  108 lines

  1. /*
  2. **    GadTools layout toolkit
  3. **
  4. **    Copyright © 1993-1996 by Olaf `Olsen' Barthel
  5. **        Freely distributable.
  6. **
  7. **    :ts=4
  8. */
  9.  
  10. #ifndef _GTLAYOUT_GLOBAL_H
  11. #include "gtlayout_global.h"
  12. #endif
  13.  
  14. VOID
  15. LTP_HandleHistory(struct SGWork *Work)
  16. {
  17.     ObjectNode *Node;
  18.  
  19.     if(GETOBJECT(Work->Gadget,Node))
  20.     {
  21.         if(Node->Special.String.HistoryHook)
  22.         {
  23.             struct Node    *Choice;
  24.             struct MinList *List;
  25.  
  26.             Choice    = NULL;
  27.             List    = Node->Special.String.HistoryHook->h_Data;
  28.  
  29.             if(Work->IEvent->ie_Qualifier & QUALIFIER_SHIFT)
  30.             {
  31.                 if(Work->IEvent->ie_Code == CURSORUP)
  32.                 {
  33.                     if(List->mlh_Head->mln_Succ)
  34.                         Choice = (struct Node *)List->mlh_Head;
  35.                 }
  36.                 else
  37.                 {
  38.                     if(List->mlh_Head->mln_Succ)
  39.                         Choice = (struct Node *)List->mlh_TailPred;
  40.                 }
  41.             }
  42.             else
  43.             {
  44.                 struct Node *Current = Node->Special.String.CurrentNode;
  45.  
  46.                 if(Work->IEvent->ie_Code == CURSORUP)
  47.                 {
  48.                     if(Current)
  49.                     {
  50.                         if(Current->ln_Pred->ln_Pred)
  51.                             Choice = Current->ln_Pred;
  52.                         else
  53.                             Choice = Current;
  54.                     }
  55.                     else
  56.                     {
  57.                         if(List->mlh_Head->mln_Succ)
  58.                             Choice = (struct Node *)List->mlh_TailPred;
  59.                     }
  60.                 }
  61.                 else
  62.                 {
  63.                     if(Current)
  64.                     {
  65.                         if(Current->ln_Succ->ln_Succ)
  66.                             Choice = Current->ln_Succ;
  67.                     }
  68.                 }
  69.             }
  70.  
  71.             if(Choice != Node->Special.String.CurrentNode)
  72.             {
  73.                 LONG Len;
  74.  
  75.                 if(Choice)
  76.                 {
  77.                     Len = strlen(Choice->ln_Name);
  78.  
  79.                     if(Len >= Work->StringInfo->MaxChars)
  80.                         Len = MAX(0,Work->StringInfo->MaxChars - 1);
  81.  
  82.                     if(Len > 0)
  83.                         CopyMem(Choice->ln_Name,Work->WorkBuffer,Len);
  84.                 }
  85.                 else
  86.                     Len = 0;
  87.  
  88.                 Work->WorkBuffer[Len]    = 0;
  89.                 Work->NumChars            = Len;
  90.                 Work->BufferPos            = Len;
  91.  
  92.                 if(Node->Type == INTEGER_KIND)
  93.                 {
  94. #ifdef DO_HEXHOOK
  95.                     LTP_ConvertNum((Node->Min < 0),Work->WorkBuffer,&Work->LongInt);
  96. #else
  97.                     Work->LongInt = LTP_Atol(Work->WorkBuffer);
  98. #endif    /* DO_HEXHOOK */
  99.                 }
  100.  
  101.                 Node->Special.String.CurrentNode = Choice;
  102.  
  103.                 Work->Actions = (Work->Actions & ~SGA_BEEP) | SGA_USE | SGA_REDISPLAY;
  104.             }
  105.         }
  106.     }
  107. }
  108.